from rest_framework_jwt.utils import jwt_response_payload_handler
from rest_framework_jwt.utils import jwt_payload_handler  ## 划线说明以后可能不使用这个函数了


def user_response_payload_handler(token, user=None, request=None):
    return {'token': token,
            'username': user.username,
            'user_id': user.id}


def user_payload_handler(user):
    payload = jwt_payload_handler(user)
    payload['mobile'] = user.mobile

    if 'email' in payload:
        del payload['email']
    return payload
